package com.ruoyi.movie.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.movie.domain.MoviePhoto;
import com.ruoyi.movie.service.IMoviePhotoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 电影图片Controller
 *
 * @author ruoyi
 * @date 2025-01-29
 */
@RestController
@RequestMapping("/movie/photo")
public class MoviePhotoController extends BaseController
{
    @Autowired
    private IMoviePhotoService moviePhotoService;

    /**
     * 查询电影图片列表
     */
    @PreAuthorize("@ss.hasPermi('movie:photo:list')")
    @GetMapping("/list")
    public TableDataInfo list(MoviePhoto moviePhoto)
    {
        startPage();
        List<MoviePhoto> list = moviePhotoService.selectMoviePhotoList(moviePhoto);
        return getDataTable(list);
    }

    /**
     * 导出电影图片列表
     */
    @PreAuthorize("@ss.hasPermi('movie:photo:export')")
    @Log(title = "电影图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MoviePhoto moviePhoto)
    {
        List<MoviePhoto> list = moviePhotoService.selectMoviePhotoList(moviePhoto);
        ExcelUtil<MoviePhoto> util = new ExcelUtil<MoviePhoto>(MoviePhoto.class);
        util.exportExcel(response, list, "电影图片数据");
    }

    /**
     * 获取电影图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('movie:photo:query')")
    @GetMapping(value = "/{moviePhotoId}")
    public AjaxResult getInfo(@PathVariable("moviePhotoId") Integer moviePhotoId)
    {
        return success(moviePhotoService.selectMoviePhotoByMoviePhotoId(moviePhotoId));
    }

    /**
     * 新增电影图片
     */
    @PreAuthorize("@ss.hasPermi('movie:photo:add')")
    @Log(title = "电影图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MoviePhoto moviePhoto)
    {
        return toAjax(moviePhotoService.insertMoviePhoto(moviePhoto));
    }

    /**
     * 修改电影图片
     */
    @PreAuthorize("@ss.hasPermi('movie:photo:edit')")
    @Log(title = "电影图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MoviePhoto moviePhoto)
    {
        return toAjax(moviePhotoService.updateMoviePhoto(moviePhoto));
    }

    /**
     * 删除电影图片
     */
    @PreAuthorize("@ss.hasPermi('movie:photo:remove')")
    @Log(title = "电影图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{moviePhotoIds}")
    public AjaxResult remove(@PathVariable Integer[] moviePhotoIds)
    {
        return toAjax(moviePhotoService.deleteMoviePhotoByMoviePhotoIds(moviePhotoIds));
    }
}
